﻿using HandyControl.Controls;
using Ping9719.WpfEx;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace BaseUi.Views.PlcView
{
    /// <summary>
    /// ColdBoxTakeView.xaml 的交互逻辑冷库取放点1页面
    /// </summary>
    public partial class ColdBoxTakeView : UserControlBase
    {
        public ColdBoxTakeView()
        {
            InitializeComponent();
        }
        private void loadFirst(object sender, EventArgs e)
        {
            if (this.IsInDesignMode)
                return;
            Getnewcold1();
        }

        private void coleboxButton_Click(object sender, RoutedEventArgs e)
        {
            Getnewcold1();
        }

        private void Getnewcold1()
        {
            var ioi = LocalStatic.Plc.Read<float>("1272");
            if (ioi.IsSucceed==false)
            {
                CodeBox1g1.Text = "未接收";
            }
            else
            {
                CodeBox1g1.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1274");
            if (ioi.IsSucceed == false)
            {
                CodeBox1g2.Text = "未接收";
            }
            else
            {
                CodeBox1g2.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1276");
            if (ioi.IsSucceed == false)
            {
                CodeBox1g3.Text = "未接收";
            }
            else
            {
                CodeBox1g3.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1278");
            if (ioi.IsSucceed == false)
            {
                CodeBox1g4.Text = "未接收";
            }
            else
            {
                CodeBox1g4.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1280");
            if (ioi.IsSucceed == false)
            {
                CodeBox1g5.Text = "未接收";
            }
            else
            {
                CodeBox1g5.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1282");
            if (ioi.IsSucceed == false)
            {
                CodeBox1g6.Text = "未接收";
            }
            else
            {
                CodeBox1g6.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1284");
            if (ioi.IsSucceed == false)
            {
                CodeBox1g7.Text = "未接收";
            }
            else
            {
                CodeBox1g7.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1286");
            if (ioi.IsSucceed == false)
            {
                CodeBox1g8.Text = "未接收";
            }
            else
            {
                CodeBox1g8.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1288");
            if (ioi.IsSucceed == false)
            {
                CodeBox1g9.Text = "未接收";
            }
            else
            {
                CodeBox1g9.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1326");
            if (ioi.IsSucceed == false)
            {
                CodeBox2g1.Text = "未接收";
            }
            else
            {
                CodeBox2g1.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1328");
            if (ioi.IsSucceed == false)
            {
                CodeBox2g2.Text = "未接收";
            }
            else
            {
                CodeBox2g2.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1330");
            if (ioi.IsSucceed == false)
            {
                CodeBox2g3.Text = "未接收";
            }
            else
            {
                CodeBox2g3.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1332");
            if (ioi.IsSucceed == false)
            {
                CodeBox2g4.Text = "未接收";
            }
            else
            {
                CodeBox2g4.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1334");
            if (ioi.IsSucceed == false)
            {
                CodeBox2g5.Text = "未接收";
            }
            else
            {
                CodeBox2g5.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1336");
            if (ioi.IsSucceed == false)
            {
                CodeBox2g6.Text = "未接收";
            }
            else
            {
                CodeBox2g6.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1338");
            if (ioi.IsSucceed == false)
            {
                CodeBox2g7.Text = "未接收";
            }
            else
            {
                CodeBox2g7.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1340");
            if (ioi.IsSucceed == false)
            {
                CodeBox2g8.Text = "未接收";
            }
            else
            {
                CodeBox2g8.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1342");
            if (ioi.IsSucceed == false)
            {
                CodeBox2g9.Text = "未接收";
            }
            else
            {
                CodeBox2g9.Text = ioi.Value.ToString();
            }
            //CodeBox1g1.Text = LocalStatic.Plc.Read<float>("1272").Value.ToString();
            //CodeBox1g2.Text = LocalStatic.Plc.Read<float>("1274").Value.ToString();
            //CodeBox1g3.Text = LocalStatic.Plc.Read<float>("1276").Value.ToString();
            //CodeBox1g4.Text = LocalStatic.Plc.Read<float>("1278").Value.ToString();
            //CodeBox1g5.Text = LocalStatic.Plc.Read<float>("1280").Value.ToString();
            //CodeBox1g6.Text = LocalStatic.Plc.Read<float>("1282").Value.ToString();
            //CodeBox1g7.Text = LocalStatic.Plc.Read<float>("1284").Value.ToString();
            //CodeBox1g8.Text = LocalStatic.Plc.Read<float>("1286").Value.ToString();
            //CodeBox1g9.Text = LocalStatic.Plc.Read<float>("1288").Value.ToString();
            //CodeBox2g1.Text = LocalStatic.Plc.Read<float>("1326").Value.ToString();
            //CodeBox2g2.Text = LocalStatic.Plc.Read<float>("1328").Value.ToString();
            //CodeBox2g3.Text = LocalStatic.Plc.Read<float>("1330").Value.ToString();
            //CodeBox2g4.Text = LocalStatic.Plc.Read<float>("1332").Value.ToString();
            //CodeBox2g5.Text = LocalStatic.Plc.Read<float>("1334").Value.ToString();
            //CodeBox2g6.Text = LocalStatic.Plc.Read<float>("1336").Value.ToString();
            //CodeBox2g7.Text = LocalStatic.Plc.Read<float>("1338").Value.ToString();
            //CodeBox2g8.Text = LocalStatic.Plc.Read<float>("1340").Value.ToString();
            //CodeBox2g9.Text = LocalStatic.Plc.Read<float>("1342").Value.ToString();
        }

        private void Label_ColdBoxDoubleClick1g1(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(CodeBox1g1.Text);
                var ioi = LocalStatic.Plc.Write<float>("1272", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdBoxDoubleClick1g2(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(CodeBox1g2.Text);
                var ioi = LocalStatic.Plc.Write<float>("1274", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdBoxDoubleClick1g3(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(CodeBox1g3.Text);
                var ioi = LocalStatic.Plc.Write<float>("1276", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdBoxDoubleClick1g4(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(CodeBox1g4.Text);
                var ioi = LocalStatic.Plc.Write<float>("1278", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdBoxDoubleClick1g5(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(CodeBox1g5.Text);
                var ioi = LocalStatic.Plc.Write<float>("1280", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdBoxDoubleClick1g6(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(CodeBox1g6.Text);
                var ioi = LocalStatic.Plc.Write<float>("1282", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdBoxDoubleClick1g7(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(CodeBox1g7.Text);
                var ioi = LocalStatic.Plc.Write<float>("1284", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdBoxDoubleClick1g8(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(CodeBox1g8.Text);
                var ioi = LocalStatic.Plc.Write<float>("1286", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdBoxDoubleClick1g9(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(CodeBox1g9.Text);
                var ioi = LocalStatic.Plc.Write<float>("1288", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdBoxDoubleClick2g1(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(CodeBox2g1.Text);
                var ioi = LocalStatic.Plc.Write<float>("1326", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdBoxDoubleClick2g2(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(CodeBox2g2.Text);
                var ioi = LocalStatic.Plc.Write<float>("1328", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdBoxDoubleClick2g3(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(CodeBox2g3.Text);
                var ioi = LocalStatic.Plc.Write<float>("1330", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdBoxDoubleClick2g4(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(CodeBox2g4.Text);
                var ioi = LocalStatic.Plc.Write<float>("1332", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdBoxDoubleClick2g5(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(CodeBox2g5.Text);
                var ioi = LocalStatic.Plc.Write<float>("1334", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdBoxDoubleClick2g6(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(CodeBox2g6.Text);
                var ioi = LocalStatic.Plc.Write<float>("1336", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdBoxDoubleClick2g7(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(CodeBox2g7.Text);
                var ioi = LocalStatic.Plc.Write<float>("1338", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdBoxDoubleClick2g8(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(CodeBox2g8.Text);
                var ioi = LocalStatic.Plc.Write<float>("1340", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdBoxDoubleClick2g9(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(CodeBox2g9.Text);
                var ioi = LocalStatic.Plc.Write<float>("1342", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }
    }
}
